package nowCoder;

import java.util.Stack;

/**
 * Created by Ghost on 2015/4/8.
 */
public class StackAsQueue {
    Stack<Integer> stack1 = new Stack<Integer>();
    Stack<Integer> stack2 = new Stack<Integer>();

    public void push(int node) {
        stack1.push(node);
    }

    public int pop() {
        while(!stack1.empty()){
            int tmp = stack1.pop();
            stack2.push(tmp);
        }

        int rst = stack2.pop();
        while(!stack2.empty()){
            int tmp = stack2.pop();
            stack1.push(tmp);
        }
        return rst;
    }
}
